home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgramD2.iso / Borland / Borland C++ V5.02 / SCRIPT.PAK / MISCSCR.SPP < prev    next >
Text File  |  1997-05-06  |  4KB  |  168 lines

  1. //----------------------------------------------------------------------------
  2. // cScript
  3. // (C) Copyright 1987, 1997 by Borland International, All Rights Reserved
  4. //
  5. // IDE.SPP
  6. //    IDE top level event handling.
  7. //
  8. // $Revision:   1.9  $
  9. //
  10. //----------------------------------------------------------------------------
  11.  
  12.  
  13. // This file directly accesses functionality provided by the Windows API
  14. // through the dynamically loaded library MISCSCR.DLL.  Check the file:
  15. // MISCSCR.CPP in the EXAMPLES\SCRIPT\SOURCE directory to see the 
  16. // implementation of the functions referenced here.
  17.  
  18. import IDE;
  19.  
  20. print "Processing MISCSCR.SPP script extensions.";
  21.  
  22. import "MISCSCR.DLL" {
  23.    char CreateDirectory(char *);
  24.    char RemoveDirectory(char *);
  25.    char SetCurrentDirectory(const char *);
  26.    const char *GetCurrentDirectory();
  27.    void Abort();
  28.    void IDEMessageBeep(int);
  29.    char * FindFirstFile(char *);
  30.    char * FindNextFile();
  31.    char * GetEnvironmentVariable(char *);
  32.    void AssociateButton(int, char *);
  33.    char PlaySound(char *, int);
  34.    char CopyFile(char *, char *, bool);
  35.    char DeleteFile(char *);
  36.    char MoveFile(char *, char *);
  37.    unsigned GetFileAttributes(char *);
  38.    char SetFileAttributes(char *, unsigned);
  39.    char FileExists(char *);
  40.    char IsLegalFileName(char *);
  41.    char Spawn(const char *);
  42.    char *GetValueData(int, const char *, const char *);
  43.    char SetValueData(int, const char *, const char *, const char *);
  44.    char *GetMainMenuHotKeys();
  45. }
  46.  
  47. on IDE:>CreateDirectory(dirName){
  48.    return CreateDirectory(dirName);
  49. }
  50.  
  51. on IDE:>RemoveDirectory(fileName){
  52.    return RemoveDirectory(fileName);
  53. }
  54.  
  55. on IDE:>Abort(){
  56.    Abort();
  57. }
  58.  
  59. on IDE:>MessageBeep(soundType){
  60.    IDEMessageBeep(soundType);
  61. }
  62.  
  63. on IDE:>FindFirstFile(filePattern){
  64.    return FindFirstFile(filePattern);
  65. }
  66.  
  67. on IDE:>FindNextFile(){
  68.    return FindNextFile();
  69. }
  70.  
  71. on IDE:>GetEnvironmentVariable(envVar){
  72.    return GetEnvironmentVariable(envVar);
  73. }
  74.  
  75. on IDE:>AssociateButton(resId, scriptToExecute){
  76.    return AssociateButton(resId, scriptToExecute);
  77. }
  78.  
  79. on IDE:>PlaySound(wavFile, optionsMask){
  80.    return PlaySound(wavFile, optionsMask);
  81. }
  82.  
  83. on IDE:>CopyFile(src, dst, overWrite){
  84.    return CopyFile(src, dst, overWrite);
  85. }
  86.  
  87. on IDE:>DeleteFile(fileName){
  88.    return DeleteFile(fileName);
  89. }
  90.  
  91. on IDE:>MoveFile(src, dst){
  92.    return MoveFile(src, dst);
  93. }
  94.  
  95. on IDE:>GetFileAttributes(fileName){
  96.    return GetFileAttributes(fileName);
  97. }
  98.  
  99. on IDE:>SetFileAttributes(fileName, newAttrs){
  100.    return SetFileAttributes(fileName, newAttrs);
  101. }
  102.  
  103. on IDE:>FileExists(fileName){
  104.    return FileExists(fileName);
  105. }
  106.  
  107. on IDE:>IsLegalFileName(fileName){
  108.    return IsLegalFileName(fileName);
  109. }
  110.  
  111. on IDE:>Spawn(cmdLine){
  112.    return Spawn(cmdLine);
  113. }
  114.  
  115. on IDE:>GetValueData(topKey, subKey, valueName){
  116.    return GetValueData(topKey, subKey, valueName);
  117. }
  118.  
  119. on IDE:>SetValueData(topKey, subKey, valueName, valueData){
  120.    return SetValueData(topKey, subKey, valueName, valueData);
  121. }
  122.  
  123. FormatString(formatSpecifier, str1, str2, str3, str4, str5, str6, str7, str8, str9, str10,
  124.                  str11, str12, str13, str14, str15, str16, str17, str18, str19, str20)
  125. {
  126.  
  127.   // get the stack frame
  128.   declare stk = new StackFrame (1);
  129.  
  130.   // get the number of arguments
  131.   declare args = stk.ArgActual;
  132.  
  133.   // get the format specifier
  134.   declare input = formatSpecifier;
  135.  
  136.   // process arguments, starting with the last
  137.   for (declare i=args-1; i>=1; i--) {
  138.  
  139.     // we will search for %1, %2, etc.
  140.     declare specifier ="";
  141.     specifier = "%" + i;
  142.      
  143.     // find length of specifier
  144.     declare len;
  145.     if (i>9) len = 3; else len = 2;
  146.      
  147.     // get the string to insert
  148.     declare insert = stk.GetParm(i);
  149.  
  150.     declare inputStr = new String(input);
  151.     declare idx = inputStr.Index(specifier, SEARCH_FORWARD);
  152.  
  153.     while (idx > 0) {
  154.  
  155.       if (idx==1) {
  156.         input = insert + inputStr.SubString(idx-1+len).Text;
  157.       } else {
  158.         input = inputStr.SubString(0, idx-1).Text + insert;
  159.         if (idx-1+len < inputStr.Length)
  160.           input += inputStr.SubString(idx-1+len).Text;
  161.       } 
  162.       inputStr = new String(input);
  163.       idx = inputStr.Index(specifier, SEARCH_FORWARD);                                  
  164.     }
  165.   }
  166.   return input;
  167. }
  168.